﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.ComponentModel;
using Android.App;
using System.Diagnostics;
using Android.Runtime;
using ComApp;

namespace AndroidApp
{
    [Application(Debuggable = true, Label = "SiAi", Icon = "@drawable/icon", Theme="@android:style/Theme.Light.NoTitleBar")]
    public class ApplicationContext:Application
    {
        protected ApplicationContext(IntPtr javaReference, JniHandleOwnership transfer)
            : base(javaReference, transfer)
        {
        }

        public override void OnCreate()
        {
            base.OnCreate();
            FileLog.Instance.Log("Application.OnCreate");
            //this.RegisterActivityLifecycleCallbacks(new ActivityLifecycleCallbacks());
        }
    }

    public class ActivityLifecycleCallbacks : Android.App.Application.IActivityLifecycleCallbacks
    {
        public void OnActivityCreated(Activity activity, Android.OS.Bundle savedInstanceState)
        {
            AppUnity.Instance.LogService.Log(activity.GetType().FullName + ".OnActivityCreated");
        }

        public void OnActivityDestroyed(Activity activity)
        {
            AppUnity.Instance.LogService.Log(activity.GetType().FullName + ".OnActivityDestroyed");
        }

        public void OnActivityPaused(Activity activity)
        {
            AppUnity.Instance.LogService.Log(activity.GetType().FullName + ".OnActivityPaused");
        }

        public void OnActivityResumed(Activity activity)
        {
            AppUnity.Instance.LogService.Log(activity.GetType().FullName + ".OnActivityResumed");
        }

        public void OnActivitySaveInstanceState(Activity activity, Android.OS.Bundle outState)
        {
            AppUnity.Instance.LogService.Log(activity.GetType().FullName + ".OnActivitySaveInstanceState");
        }

        public void OnActivityStarted(Activity activity)
        {
            AppUnity.Instance.LogService.Log(activity.GetType().FullName + ".OnActivityStarted");
        }

        public void OnActivityStopped(Activity activity)
        {
            AppUnity.Instance.LogService.Log(activity.GetType().FullName + ".OnActivityStopped");
        }

        public void Dispose()
        {
            AppUnity.Instance.LogService.Log("ActivityLifecycleCallbacks.Dispose");
        }

        public IntPtr Handle
        {
            get { return IntPtr.Zero; }
        }
    }

}
